package com.springboot.news.controller;

import com.springboot.news.domain.dto.OcrTextDTO;
import com.springboot.news.domain.po.Result;
import com.springboot.news.domain.query.OcrTextQuery;
import com.springboot.news.domain.vo.OcrTextVo;
import com.springboot.news.domain.vo.PageableVO;
import com.springboot.news.service.OcrTextService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/ocrText")
public class OcrController {

    @Resource
    private OcrTextService ocrTextService;

    @PostMapping("/tableList")
    public Result<PageableVO<OcrTextVo>> tableList (@RequestBody OcrTextQuery dto) {
        return Result.success(ocrTextService.tableList(dto));
    }

    @PostMapping("/addOcrText")
    public Result<String> addOcrText(@RequestBody OcrTextDTO dto) {
        ocrTextService.addOcrText(dto);
        return Result.success("添加成功");
    }

    @PostMapping("/updateOcrText")
    public Result<String> updateOcrText(@RequestBody OcrTextDTO dto) {
        ocrTextService.updateOcrText(dto);
        return Result.success("编辑成功");
    }
    
    @DeleteMapping("/deleteOcrText")
    public Result<String> deleteOcrText(@RequestParam Integer id) {
        ocrTextService.deleteOcrText(id);
        return Result.success("删除成功");
    }

    @GetMapping("/ocrTextDetail")
    public Result<OcrTextVo> ocrTextDetail(@RequestParam Integer id) {
        OcrTextVo vo = ocrTextService.ocrTextDetail(id);
        return Result.success(vo);
    }
}
